package com.leapp.sk.ui.activity.classs

import android.content.Intent
import android.os.Bundle
import android.view.View
import com.example.mvp.activity.BaseActivityMVP
import com.example.mvp.binder.BaseDataBinder
import com.leapp.sk.R
import com.leapp.sk.bean.ChoseClassEntity
import com.leapp.sk.binder.BaseBinder
import com.leapp.sk.ui.activity.notify.SendNotifyActivity
import com.leapp.sk.ui.activity.task.CompleteTaskActivity
import com.example.util.finallist.CHOSE_CLASS_NAME
import com.example.util.finallist.CODE_205
import com.example.util.finallist.IS_TASK
import com.leapp.sk.viewdelegate.classs.ChoseClassDelegate

/**
 * 选择班级
 * @author  chaohaipeng  on 2018/8/2.
 */
class ChoseClassActivity:BaseActivityMVP<ChoseClassDelegate>() {

    /**
     * 是作业
     */
var isTask:Boolean?=false
    override fun initView(p0: Bundle?) {
        viewDelegate.setTitle(resources.getString(R.string.app_chose_class))
    }

    override fun initDate() {
         isTask = intent?.getBooleanExtra(IS_TASK, false)
        val mutableListOf = mutableListOf<ChoseClassEntity>()
        val choseClassEntity = ChoseClassEntity()
        choseClassEntity.className="香蕉1班"
        val choseClassEntity1 = ChoseClassEntity()
        choseClassEntity1.className="香蕉2班"
        mutableListOf.add(choseClassEntity)
        mutableListOf.add(choseClassEntity1)
        viewDelegate.initAdapter(mutableListOf)

    }

    override fun bindEvenListener() {
        viewDelegate.setOnClickListener(View.OnClickListener {
            if (isTask!!){
                val intent= Intent(this, CompleteTaskActivity::class.java)
            }else{
                val intent= Intent(this, SendNotifyActivity::class.java)
            }
            intent.putExtra(CHOSE_CLASS_NAME,viewDelegate.getClassName())
            setResult(CODE_205,intent)
            finish()
        }, R.id.tv_acc_confirm)



    }

    override fun getDelegateClass(): Class<ChoseClassDelegate> {
        return ChoseClassDelegate::class.java
    }

    override fun getDataBinder(): BaseDataBinder<*, *> {
        return BaseBinder()
    }
}